<template>
  <div class="common-head">
    <!-- 左半边 -->
    <div class="head-left">
      <!-- 面包屑导航 -->
      <el-breadcrumb-item>
      <i
      @click="CollapseAside"
      :class="$store.state.base.navCollapae ? 'el-icon-s-fold' : 'el-icon-s-unfold'">
        </i>
        </el-breadcrumb-item>

      <el-breadcrumb separator="/">

        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item v-if="$route.path !== '/home'">{{$route.name}}</el-breadcrumb-item>
      </el-breadcrumb>
      <!-- 面包屑导航 -->
    </div>
    <!-- 左半边 -->
     <div class="head-rt el-dropdown-link">
        <i class="el-icon-search rt-icon" ></i>
        <i class="el-icon-refresh rt-icon" @click="PageLoad"></i>
        <i class="el-icon-full-screen rt-icon"></i>
      <el-dropdown @command="TuiChu">
      <div class="user">
        <span class="user-info">{{$store.state.user.user.userName}}</span>
        <div>
          <el-avatar :src="$store.state.user.user.headIocn"/>
        </div>
      </div>
      <el-dropdown-menu slot="dropdown" >
        <el-dropdown-item command="userInfo">个人中心</el-dropdown-item>
        <el-dropdown-item command="loginOut"> 退出账号</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
    </div>
  </div>
</template>
<script>
export default {
  methods: {
    CollapseAside () {
      // console.log(111);
      console.log(this.$store)
      this.$store.commit('base/AsideCollapse')
    },
    // 退出登录
    TuiChu (action) {
      if (action === 'loginOut') {
        this.$store.commit('user/CLEAR_USER')
        this.$router.go(0)
      } else if (action === 'userInfo') {
        this.$router.push('/userInfo')
      }
    },
    // 刷新
    PageLoad () {
      this.$router.go(0)
    },
    toggleMenu () {
      this.$store.commit('nav/TOGGLE_MENU')
    }
  }

}
</script>

<style lang="scss" scoped>
.common-head{
  height: 100%;
  display: flex;
  justify-content: space-between;
  .head-left{
    display: flex;
    align-items: center;
    i{
      font-size: 20px;
      cursor: pointer;
    }
  }
  .rt-icon{
      font-size: 18px;
      margin-right: 10px;
      cursor: pointer;
    }
  .user{
    height: 60px;
    cursor: pointer;
    display: flex;
    align-items: center;
    &-info{
      margin-right: 10px;
    }
  }

}

</style>
